<!DOCTYPE html>
<html lang="zh" dir="ltr" class="client-nojs">
<head>
<title>operator new, operator new[]</title>
<meta charset="UTF-8">
<meta name="generator" content="MediaWiki 1.21.2">
<link rel="shortcut icon" href="../../../../common/favicon.ico">
<link rel="stylesheet" href="../../../../common/ext.css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" href="../../../../common/site_modules.css">
<style>a:lang(ar),a:lang(ckb),a:lang(fa),a:lang(kk-arab),a:lang(mzn),a:lang(ps),a:lang(ur){text-decoration:none}#toc{display:none}.editsection{display:none}
/* cache key: mwiki1-mwiki_zh_:resourceloader:filter:minify-css:7:15cea3ec788a65b5187d4018eed543bf */</style>

<script src="../../../../common/startup_scripts.js"></script>
<script>if(window.mw){
mw.config.set({"wgCanonicalNamespace":"","wgCanonicalSpecialPageName":false,"wgNamespaceNumber":0,"wgPageName":"cpp/memory/new/operator_new","wgTitle":"cpp/memory/new/operator new","wgCurRevisionId":65278,"wgArticleId":2958,"wgIsArticle":true,"wgAction":"view","wgUserName":null,"wgUserGroups":["*"],"wgCategories":["Todo no example"],"wgBreakFrames":false,"wgPageContentLanguage":"zh","wgSeparatorTransformTable":["",""],"wgDigitTransformTable":["",""],"wgDefaultDateFormat":"zh","wgMonthNames":["","1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],"wgMonthNamesShort":["","1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],"wgRelevantPageName":"cpp/memory/new/operator_new","wgUserVariant":"zh","wgRestrictionEdit":[],"wgRestrictionMove":[]});
}</script><script>if(window.mw){
mw.loader.implement("user.options",function(){mw.user.options.set({"ccmeonemails":0,"cols":80,"date":"default","diffonly":0,"disablemail":0,"disablesuggest":0,"editfont":"default","editondblclick":0,"editsection":0,"editsectiononrightclick":0,"enotifminoredits":0,"enotifrevealaddr":0,"enotifusertalkpages":1,"enotifwatchlistpages":0,"extendwatchlist":0,"externaldiff":0,"externaleditor":0,"fancysig":0,"forceeditsummary":0,"gender":"unknown","hideminor":0,"hidepatrolled":0,"imagesize":2,"justify":0,"math":1,"minordefault":0,"newpageshidepatrolled":0,"nocache":0,"noconvertlink":0,"norollbackdiff":0,"numberheadings":0,"previewonfirst":0,"previewontop":1,"quickbar":5,"rcdays":7,"rclimit":50,"rememberpassword":0,"rows":25,"searchlimit":20,"showhiddencats":0,"showjumplinks":1,"shownumberswatching":1,"showtoc":0,"showtoolbar":1,"skin":"cppreference2","stubthreshold":0,"thumbsize":2,"underline":2,"uselivepreview":0,"usenewrc":0,"watchcreations":0,"watchdefault":0,"watchdeletion":0,
"watchlistdays":3,"watchlisthideanons":0,"watchlisthidebots":0,"watchlisthideliu":0,"watchlisthideminor":0,"watchlisthideown":0,"watchlisthidepatrolled":0,"watchmoves":0,"wllimit":250,"variant":"zh","language":"zh","searchNs0":true,"searchNs1":false,"searchNs2":false,"searchNs3":false,"searchNs4":false,"searchNs5":false,"searchNs6":false,"searchNs7":false,"searchNs8":false,"searchNs9":false,"searchNs10":false,"searchNs11":false,"searchNs12":false,"searchNs13":false,"searchNs14":false,"searchNs15":false,"gadget-MathJax":1,"gadget-ColiruCompiler":1});;},{},{});mw.loader.implement("user.tokens",function(){mw.user.tokens.set({"editToken":"+\\","patrolToken":false,"watchToken":false});;},{},{});
/* cache key: mwiki1-mwiki_zh_:resourceloader:filter:minify-js:7:258d7cd6aa9aa67dee25e01fb6a9e505 */
}</script>
<script>if(window.mw){
mw.loader.load(["mediawiki.page.startup","mediawiki.legacy.wikibits","mediawiki.legacy.ajax"]);
}</script>
<style type="text/css">/*<![CDATA[*/
.source-cpp {line-height: normal;}
.source-cpp li, .source-cpp pre {
	line-height: normal; border: 0px none white;
}
/**
 * GeSHi Dynamically Generated Stylesheet
 * --------------------------------------
 * Dynamically generated stylesheet for cpp
 * CSS class: source-cpp, CSS id: 
 * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
 * (http://qbnz.com/highlighter/ and http://geshi.org/)
 * --------------------------------------
 */
.cpp.source-cpp .de1, .cpp.source-cpp .de2 {font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;}
.cpp.source-cpp  {font-family:monospace;}
.cpp.source-cpp .imp {font-weight: bold; color: red;}
.cpp.source-cpp li, .cpp.source-cpp .li1 {font-weight: normal; vertical-align:top;}
.cpp.source-cpp .ln {width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;}
.cpp.source-cpp .li2 {font-weight: bold; vertical-align:top;}
.cpp.source-cpp .kw1 {color: #0000dd;}
.cpp.source-cpp .kw2 {color: #0000ff;}
.cpp.source-cpp .kw3 {color: #0000dd;}
.cpp.source-cpp .kw4 {color: #0000ff;}
.cpp.source-cpp .co1 {color: #909090;}
.cpp.source-cpp .co2 {color: #339900;}
.cpp.source-cpp .coMULTI {color: #ff0000; font-style: italic;}
.cpp.source-cpp .es0 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es1 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es2 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es3 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es4 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es5 {color: #008000; font-weight: bold;}
.cpp.source-cpp .br0 {color: #008000;}
.cpp.source-cpp .sy0 {color: #008000;}
.cpp.source-cpp .sy1 {color: #000080;}
.cpp.source-cpp .sy2 {color: #000040;}
.cpp.source-cpp .sy3 {color: #000040;}
.cpp.source-cpp .sy4 {color: #008080;}
.cpp.source-cpp .st0 {color: #008000;}
.cpp.source-cpp .nu0 {color: #000080;}
.cpp.source-cpp .nu6 {color: #000080;}
.cpp.source-cpp .nu8 {color: #000080;}
.cpp.source-cpp .nu12 {color: #000080;}
.cpp.source-cpp .nu16 {color:#000080;}
.cpp.source-cpp .nu17 {color:#000080;}
.cpp.source-cpp .nu18 {color:#000080;}
.cpp.source-cpp .nu19 {color:#000080;}
.cpp.source-cpp .ln-xtra, .cpp.source-cpp li.ln-xtra, .cpp.source-cpp div.ln-xtra {background-color: #ffc;}
.cpp.source-cpp span.xtra { display:block; }

/*]]>*/
</style><style type="text/css">/*<![CDATA[*/
.source-text {line-height: normal;}
.source-text li, .source-text pre {
	line-height: normal; border: 0px none white;
}
/**
 * GeSHi Dynamically Generated Stylesheet
 * --------------------------------------
 * Dynamically generated stylesheet for text
 * CSS class: source-text, CSS id: 
 * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
 * (http://qbnz.com/highlighter/ and http://geshi.org/)
 * --------------------------------------
 */
.text.source-text .de1, .text.source-text .de2 {font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;}
.text.source-text  {font-family:monospace;}
.text.source-text .imp {font-weight: bold; color: red;}
.text.source-text li, .text.source-text .li1 {font-weight: normal; vertical-align:top;}
.text.source-text .ln {width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;}
.text.source-text .li2 {font-weight: bold; vertical-align:top;}
.text.source-text .ln-xtra, .text.source-text li.ln-xtra, .text.source-text div.ln-xtra {background-color: #ffc;}
.text.source-text span.xtra { display:block; }

/*]]>*/
</style><!--[if lt IE 7]><style type="text/css">body{behavior:url("/mwiki/skins/cppreference2/csshover.min.htc")}</style><![endif]--></head>
<body class="mediawiki ltr sitedir-ltr ns-0 ns-subject page-cpp_memory_new_operator_new skin-cppreference2 action-view cpp-navbar">
        <!-- header -->
        <!-- /header -->
        <!-- content -->
<div id="cpp-content-base">
            <div id="content">
                <a id="top"></a>
                <div id="mw-js-message" style="display:none;"></div>
                                <!-- firstHeading -->
<h1 id="firstHeading" class="firstHeading"><span style="font-size:0.7em; line-height:130%">operator</span> new<span style="font-size:0.7em; line-height:130%">, operator</span> new[]</h1>
                <!-- /firstHeading -->
                <!-- bodyContent -->
                <div id="bodyContent">
                                        <!-- tagline -->
                    <div id="siteSub">来自cppreference.com</div>
                    <!-- /tagline -->
                                        <!-- subtitle -->
                    <div id="contentSub"><span class="subpages">&lt; <a href="../../../cpp.html" title="cpp">cpp</a>‎ | <a href="../../memory.html" title="cpp/memory">memory</a>‎ | <a href="../new.html" title="cpp/memory/new">new</a></span></div>
                    <!-- /subtitle -->
                                                            <!-- bodycontent -->
                    <div id="mw-content-text" lang="zh" dir="ltr" class="mw-content-ltr"><div class="t-navbar" style=""><div class="t-navbar-sep"> </div><div class="t-navbar-head"><a href="../../../cpp.html" title="cpp"> C++</a><div class="t-navbar-menu"><div><div><table class="t-nv-begin" cellpadding="0" style="line-height:1.1em;">
<tr class="t-nv"><td colspan="5"> <a href="../../language.html" title="cpp/language">语言</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../header.html" title="cpp/header">标准库头文件</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../freestanding.html" title="cpp/freestanding"> 自立与有宿主实现</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../named_req.html" title="cpp/named req">具名要求</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../utility.html#.E8.AF.AD.E8.A8.80.E6.94.AF.E6.8C.81" title="cpp/utility">语言支持库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../concepts.html" title="cpp/concepts">概念库</a> <span class="t-mark-rev t-since-cxx20">(C++20)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../error.html" title="cpp/error">诊断库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../utility.html" title="cpp/utility">工具库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../string.html" title="cpp/string">字符串库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="https://zh.cppreference.com/w/cpp/container" title="cpp/container">容器库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../iterator.html" title="cpp/iterator">迭代器库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../ranges.html" title="cpp/ranges"> 范围库</a> <span class="t-mark-rev t-since-cxx20">(C++20)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../algorithm.html" title="cpp/algorithm">算法库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../numeric.html" title="cpp/numeric">数值库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../io.html" title="cpp/io">输入/输出库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../locale.html" title="cpp/locale">本地化库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../regex.html" title="cpp/regex">正则表达式库</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../atomic.html" title="cpp/atomic">原子操作库</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../thread.html" title="cpp/thread">线程支持库</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../filesystem.html" title="cpp/filesystem">文件系统库</a> <span class="t-mark-rev t-since-cxx17">(C++17)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../experimental.html" title="cpp/experimental">技术规范</a> </td></tr>
</table></div><div></div></div></div></div><div class="t-navbar-sep"> </div><div class="t-navbar-head"><a href="../../utility.html" title="cpp/utility">工具库</a><div class="t-navbar-menu"><div><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="../../types.html" title="cpp/types">类型支持</a>（基本类型、 RTTI 、类型特性）</td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../memory.html" title="cpp/memory">动态内存管理</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../error.html" title="cpp/error">错误处理</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../utility/program.html" title="cpp/utility/program">程序工具</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../utility/variadic.html" title="cpp/utility/variadic">变参数函数</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../utility/feature_test.html" title="cpp/utility/feature test">库特性测试宏</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../chrono.html" title="cpp/chrono">日期和时间</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../utility/functional.html" title="cpp/utility/functional">函数对象</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../utility/format.html" title="cpp/utility/format"> 格式化库</a> <span class="t-mark-rev t-since-cxx20">(C++20)</span> </td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../utility/initializer_list.html" title="cpp/utility/initializer list"><span class="t-lines"><span>initializer_list</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../utility/source_location.html" title="cpp/utility/source location"><span class="t-lines"><span>source_location</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../utility/bitset.html" title="cpp/utility/bitset"><span class="t-lines"><span>bitset</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../utility/hash.html" title="cpp/utility/hash"><span class="t-lines"><span>hash</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../utility/integer_sequence.html" title="cpp/utility/integer sequence"><span class="t-lines"><span>integer_sequence</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx14">(C++14)</span></span></span></div></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 关系运算符 <span class="t-mark-rev t-deprecated-cxx20">(C++20 中弃用)</span> </td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../utility/rel_ops/operator_cmp.html" title="cpp/utility/rel ops/operator cmp"><span class="t-lines"><span>rel_ops::operator!=</span><span>rel_ops::operator&gt;</span><span>rel_ops::operator&lt;=</span><span>rel_ops::operator&gt;=</span></span></a></div></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 比较 <span class="t-mark-rev t-since-cxx20">(C++20)</span></td></tr><tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../utility/compare/three_way_comparable.html" title="cpp/utility/compare/three way comparable"><span class="t-lines"><span>three_way_comparable</span><span>three_way_comparable_with</span></span></a></div></div></td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../utility/compare/strong_ordering.html" title="cpp/utility/compare/strong ordering"><span class="t-lines"><span>strong_ordering</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../utility/compare/weak_ordering.html" title="cpp/utility/compare/weak ordering"><span class="t-lines"><span>weak_ordering</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../utility/compare/partial_ordering.html" title="cpp/utility/compare/partial ordering"><span class="t-lines"><span>partial_ordering</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../utility/compare/common_comparison_category.html" title="cpp/utility/compare/common comparison category"><span class="t-lines"><span>common_comparison_category</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../utility/compare/compare_three_way_result.html" title="cpp/utility/compare/compare three way result"><span class="t-lines"><span>compare_three_way_result</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../utility/compare/compare_three_way.html" title="cpp/utility/compare/compare three way"><span class="t-lines"><span>compare_three_way</span></span></a></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../utility/compare/strong_order.html" title="cpp/utility/compare/strong order"><span class="t-lines"><span>strong_order</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../utility/compare/weak_order.html" title="cpp/utility/compare/weak order"><span class="t-lines"><span>weak_order</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../utility/compare/partial_order.html" title="cpp/utility/compare/partial order"><span class="t-lines"><span>partial_order</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../utility/compare/compare_strong_order_fallback.html" title="cpp/utility/compare/compare strong order fallback"><span class="t-lines"><span>compare_strong_order_fallback</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../utility/compare/compare_weak_order_fallback.html" title="cpp/utility/compare/compare weak order fallback"><span class="t-lines"><span>compare_weak_order_fallback</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../utility/compare/compare_partial_order_fallback.html" title="cpp/utility/compare/compare partial order fallback"><span class="t-lines"><span>compare_partial_order_fallback</span></span></a></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../utility/compare/named_comparison_functions.html" title="cpp/utility/compare/named comparison functions"><span class="t-lines"><span>is_eq</span><span>is_neq</span><span>is_lt</span><span>is_lteq</span><span>is_gt</span><span>is_gteq</span></span></a></div></div></td></tr>
</table></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 共用词汇类型</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../utility/pair.html" title="cpp/utility/pair"><span class="t-lines"><span>pair</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../utility/tuple.html" title="cpp/utility/tuple"><span class="t-lines"><span>tuple</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../utility/apply.html" title="cpp/utility/apply"><span class="t-lines"><span>apply</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../utility/make_from_tuple.html" title="cpp/utility/make from tuple"><span class="t-lines"><span>make_from_tuple</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../utility/optional.html" title="cpp/utility/optional"><span class="t-lines"><span>optional</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../utility/any.html" title="cpp/utility/any"><span class="t-lines"><span>any</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../utility/variant.html" title="cpp/utility/variant"><span class="t-lines"><span>variant</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"> <br>
</td></tr>
</table></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> swap 、 forward 与 move</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../algorithm/swap.html" title="cpp/algorithm/swap"><span class="t-lines"><span>swap</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../utility/exchange.html" title="cpp/utility/exchange"><span class="t-lines"><span>exchange</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx14">(C++14)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../utility/forward.html" title="cpp/utility/forward"><span class="t-lines"><span>forward</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../utility/move.html" title="cpp/utility/move"><span class="t-lines"><span>move</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../utility/move_if_noexcept.html" title="cpp/utility/move if noexcept"><span class="t-lines"><span>move_if_noexcept</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 初等字符串转换</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../utility/to_chars.html" title="cpp/utility/to chars"><span class="t-lines"><span>to_chars</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../utility/from_chars.html" title="cpp/utility/from chars"><span class="t-lines"><span>from_chars</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../utility/chars_format.html" title="cpp/utility/chars format"><span class="t-lines"><span>chars_format</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 类型运算</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../utility/declval.html" title="cpp/utility/declval"><span class="t-lines"><span>declval</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../utility/as_const.html" title="cpp/utility/as const"><span class="t-lines"><span>as_const</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../utility/launder.html" title="cpp/utility/launder"><span class="t-lines"><span>launder</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
</table></div><div></div></div></div></div><div class="t-navbar-sep"> </div><div class="t-navbar-head"><a href="../../memory.html" title="cpp/memory">动态内存管理</a><div class="t-navbar-menu"><div><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv-h1"><td colspan="5"> 智能指针</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../unique_ptr.html" title="cpp/memory/unique ptr"><span class="t-lines"><span>unique_ptr</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../shared_ptr.html" title="cpp/memory/shared ptr"><span class="t-lines"><span>shared_ptr</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../weak_ptr.html" title="cpp/memory/weak ptr"><span class="t-lines"><span>weak_ptr</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../auto_ptr.html" title="cpp/memory/auto ptr"><span class="t-lines"><span>auto_ptr</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-until-cxx17">(C++17 前)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../owner_less.html" title="cpp/memory/owner less"><span class="t-lines"><span>owner_less</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../enable_shared_from_this.html" title="cpp/memory/enable shared from this"><span class="t-lines"><span>enable_shared_from_this</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../bad_weak_ptr.html" title="cpp/memory/bad weak ptr"><span class="t-lines"><span>bad_weak_ptr</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../default_delete.html" title="cpp/memory/default delete"><span class="t-lines"><span>default_delete</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv-h1"><td colspan="5"> 分配器</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../allocator.html" title="cpp/memory/allocator"><span class="t-lines"><span>allocator</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../allocator_traits.html" title="cpp/memory/allocator traits"><span class="t-lines"><span>allocator_traits</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../allocator_arg_t.html" title="cpp/memory/allocator arg t"><span class="t-lines"><span>allocator_arg_t</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../allocator_arg.html" title="cpp/memory/allocator arg"><span class="t-lines"><span>allocator_arg</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../uses_allocator.html" title="cpp/memory/uses allocator"><span class="t-lines"><span>uses_allocator</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../uses_allocator_construction_args.html" title="cpp/memory/uses allocator construction args"><span class="t-lines"><span>uses_allocator_construction_args</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../make_obj_using_allocator.html" title="cpp/memory/make obj using allocator"><span class="t-lines"><span>make_obj_using_allocator</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../uninitialized_construct_using_allocator.html" title="cpp/memory/uninitialized construct using allocator"><span class="t-lines"><span>uninitialized_construct_using_allocator</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../scoped_allocator_adaptor.html" title="cpp/memory/scoped allocator adaptor"><span class="t-lines"><span>scoped_allocator_adaptor</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../polymorphic_allocator.html" title="cpp/memory/polymorphic allocator"><span class="t-lines"><span>pmr::polymorphic_allocator</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv-h1"><td colspan="5"> 内存资源</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../memory_resource.html" title="cpp/memory/memory resource"><span class="t-lines"><span>pmr::memory_resource</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../get_default_resource.html" title="cpp/memory/get default resource"><span class="t-lines"><span>pmr::get_default_resource</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../set_default_resource.html" title="cpp/memory/set default resource"><span class="t-lines"><span>pmr::set_default_resource</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../new_delete_resource.html" title="cpp/memory/new delete resource"><span class="t-lines"><span>pmr::new_delete_resource</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../null_memory_resource.html" title="cpp/memory/null memory resource"><span class="t-lines"><span>pmr::null_memory_resource</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../synchronized_pool_resource.html" title="cpp/memory/synchronized pool resource"><span class="t-lines"><span>pmr::synchronized_pool_resource</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../unsynchronized_pool_resource.html" title="cpp/memory/unsynchronized pool resource"><span class="t-lines"><span>pmr::unsynchronized_pool_resource</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../monotonic_buffer_resource.html" title="cpp/memory/monotonic buffer resource"><span class="t-lines"><span>pmr::monotonic_buffer_resource</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../pool_options.html" title="cpp/memory/pool options"><span class="t-lines"><span>pmr::pool_options</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv-h1"><td colspan="5"> 未初始化存储</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../uninitialized_copy.html" title="cpp/memory/uninitialized copy"><span class="t-lines"><span>uninitialized_copy</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../uninitialized_fill.html" title="cpp/memory/uninitialized fill"><span class="t-lines"><span>uninitialized_fill</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../uninitialized_move.html" title="cpp/memory/uninitialized move"><span class="t-lines"><span>uninitialized_move</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../uninitialized_default_construct.html" title="cpp/memory/uninitialized default construct"><span class="t-lines"><span>uninitialized_default_construct</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../uninitialized_value_construct.html" title="cpp/memory/uninitialized value construct"><span class="t-lines"><span>uninitialized_value_construct</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../destroy.html" title="cpp/memory/destroy"><span class="t-lines"><span>destroy</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../destroy_at.html" title="cpp/memory/destroy at"><span class="t-lines"><span>destroy_at</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../uninitialized_copy_n.html" title="cpp/memory/uninitialized copy n"><span class="t-lines"><span>uninitialized_copy_n</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../uninitialized_fill_n.html" title="cpp/memory/uninitialized fill n"><span class="t-lines"><span>uninitialized_fill_n</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../uninitialized_move_n.html" title="cpp/memory/uninitialized move n"><span class="t-lines"><span>uninitialized_move_n</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../uninitialized_default_construct_n.html" title="cpp/memory/uninitialized default construct n"><span class="t-lines"><span>uninitialized_default_construct_n</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../uninitialized_value_construct_n.html" title="cpp/memory/uninitialized value construct n"><span class="t-lines"><span>uninitialized_value_construct_n</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../destroy_n.html" title="cpp/memory/destroy n"><span class="t-lines"><span>destroy_n</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../construct_at.html" title="cpp/memory/construct at"><span class="t-lines"><span>construct_at</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
</table></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../raw_storage_iterator.html" title="cpp/memory/raw storage iterator"><span class="t-lines"><span>raw_storage_iterator</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-until-cxx20">(C++20 前)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../get_temporary_buffer.html" title="cpp/memory/get temporary buffer"><span class="t-lines"><span>get_temporary_buffer</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-until-cxx20">(C++20 前)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../return_temporary_buffer.html" title="cpp/memory/return temporary buffer"><span class="t-lines"><span>return_temporary_buffer</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-until-cxx20">(C++20 前)</span></span></span></div></div></td></tr>
<tr class="t-nv-h1"><td colspan="5"> 垃圾收集支持</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../gc/declare_reachable.html" title="cpp/memory/gc/declare reachable"><span class="t-lines"><span>declare_reachable</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../gc/undeclare_reachable.html" title="cpp/memory/gc/undeclare reachable"><span class="t-lines"><span>undeclare_reachable</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../gc/declare_no_pointers.html" title="cpp/memory/gc/declare no pointers"><span class="t-lines"><span>declare_no_pointers</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../gc/undeclare_no_pointers.html" title="cpp/memory/gc/undeclare no pointers"><span class="t-lines"><span>undeclare_no_pointers</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../gc/pointer_safety.html" title="cpp/memory/gc/pointer safety"><span class="t-lines"><span>pointer_safety</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../gc/get_pointer_safety.html" title="cpp/memory/gc/get pointer safety"><span class="t-lines"><span>get_pointer_safety</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv-h1"><td colspan="5"> 杂项</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../pointer_traits.html" title="cpp/memory/pointer traits"><span class="t-lines"><span>pointer_traits</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../to_address.html" title="cpp/memory/to address"><span class="t-lines"><span>to_address</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../addressof.html" title="cpp/memory/addressof"><span class="t-lines"><span>addressof</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../align.html" title="cpp/memory/align"><span class="t-lines"><span>align</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../assume_aligned.html" title="cpp/memory/assume aligned"><span class="t-lines"><span>assume_aligned</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv-h1"><td colspan="5"> <a href="../c.html" title="cpp/memory/c">C 库</a></td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../c/malloc.html" title="cpp/memory/c/malloc"><span class="t-lines"><span>malloc</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../c/aligned_alloc.html" title="cpp/memory/c/aligned alloc"><span class="t-lines"><span>aligned_alloc</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../c/calloc.html" title="cpp/memory/c/calloc"><span class="t-lines"><span>calloc</span></span></a></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../c/realloc.html" title="cpp/memory/c/realloc"><span class="t-lines"><span>realloc</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../c/free.html" title="cpp/memory/c/free"><span class="t-lines"><span>free</span></span></a></div></div></td></tr>
</table></div></td></tr>
<tr class="t-nv-h1"><td colspan="5"> <a href="../new.html" title="cpp/memory/new">低层内存管理</a></td></tr>
</table></div></td></tr>
</table></div><div></div></div></div></div><div class="t-navbar-sep"> </div><div class="t-navbar-head"><a href="../new.html" title="cpp/memory/new">低层内存管理</a><div class="t-navbar-menu"><div><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv-h1"><td colspan="5"> 函数</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><strong class="selflink"><span class="t-lines"><span>operator new</span><span>operator new[]</span></span></strong></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="operator_delete.html" title="cpp/memory/new/operator delete"><span class="t-lines"><span>operator delete</span><span>operator delete[]</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="get_new_handler.html" title="cpp/memory/new/get new handler"><span class="t-lines"><span>get_new_handler</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="set_new_handler.html" title="cpp/memory/new/set new handler"><span class="t-lines"><span>set_new_handler</span></span></a></div></div></td></tr>
<tr class="t-nv-h1"><td colspan="5"> 类</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="bad_alloc.html" title="cpp/memory/new/bad alloc"><span class="t-lines"><span>bad_alloc</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="bad_array_new_length.html" title="cpp/memory/new/bad array new length"><span class="t-lines"><span>bad_array_new_length</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="nothrow_t.html" title="cpp/memory/new/nothrow t"><span class="t-lines"><span>nothrow_t</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="align_val_t.html" title="cpp/memory/new/align val t"><span class="t-lines"><span>align_val_t</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="destroying_delete_t.html" title="cpp/memory/new/destroying delete t"><span class="t-lines"><span>destroying_delete_t</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv-h1"><td colspan="5"> 类型</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="new_handler.html" title="cpp/memory/new/new handler"><span class="t-lines"><span>new_handler</span></span></a></div></div></td></tr>
<tr class="t-nv-h1"><td colspan="5"> 对象</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="nothrow.html" title="cpp/memory/new/nothrow"><span class="t-lines"><span>nothrow</span></span></a></div></div></td></tr>
</table></div><div></div></div></div></div><div class="t-navbar-sep"> </div></div>
<table class="t-dcl-begin"><tbody>
<tr class="t-dsc-header">
<td> <div>定义于头文件 <code><a href="../../header/new.html" title="cpp/header/new">&lt;new&gt;</a></code>
 </div></td>
<td></td>
<td></td>
</tr>
<tr class="t-dcl-sep"><td></td><td></td><td></td></tr>
<tr class="t-dcl-h">
<td> <div>可替换分配函数 <table class="t-rev-begin t-rev-begin-noborder">
<tr class="t-rev t-since-cxx20"><td>
<p><span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="br0">[</span><span class="br0">[</span>nodiscard<span class="br0">]</span><span class="br0">]</span></span></span>
</p>
</td>
<td><span class="t-mark-rev t-since-cxx20">(C++20 起)</span></td></tr>
</table></div></td>
<td></td>
<td></td>
</tr>
<tr class="t-dcl">
<td> <div><span class="mw-geshi cpp source-cpp"><span class="kw4">void</span><span class="sy2">*</span> operator new  <span class="br0">(</span> <a href="../../types/size_t.html"><span class="kw100">std::<span class="me2">size_t</span></span></a> count <span class="br0">)</span><span class="sy4">;</span></span></div></td>
<td> (1) </td>
<td class="t-dcl-nopad">  </td>
</tr>
<tr class="t-dcl">
<td> <div><span class="mw-geshi cpp source-cpp"><span class="kw4">void</span><span class="sy2">*</span> operator new<span class="br0">[</span><span class="br0">]</span><span class="br0">(</span> <a href="../../types/size_t.html"><span class="kw100">std::<span class="me2">size_t</span></span></a> count <span class="br0">)</span><span class="sy4">;</span></span></div></td>
<td> (2) </td>
<td class="t-dcl-nopad">  </td>
</tr>
<tr class="t-dcl t-since-cxx17">
<td> <div><span class="mw-geshi cpp source-cpp"><span class="kw4">void</span><span class="sy2">*</span> operator new  <span class="br0">(</span> <a href="../../types/size_t.html"><span class="kw100">std::<span class="me2">size_t</span></span></a> count, <a href="align_val_t.html"><span class="kw695">std::<span class="me2">align_val_t</span></span></a> al<span class="br0">)</span><span class="sy4">;</span></span></div></td>
<td> (3) </td>
<td> <span class="t-mark-rev t-since-cxx17">(C++17 起)</span> </td>
</tr>
<tr class="t-dcl t-since-cxx17">
<td> <div><span class="mw-geshi cpp source-cpp"><span class="kw4">void</span><span class="sy2">*</span> operator new<span class="br0">[</span><span class="br0">]</span><span class="br0">(</span> <a href="../../types/size_t.html"><span class="kw100">std::<span class="me2">size_t</span></span></a> count, <a href="align_val_t.html"><span class="kw695">std::<span class="me2">align_val_t</span></span></a> al<span class="br0">)</span><span class="sy4">;</span></span></div></td>
<td> (4) </td>
<td> <span class="t-mark-rev t-since-cxx17">(C++17 起)</span> </td>
</tr>
<tr class="t-dcl-sep"><td></td><td></td><td></td></tr>
<tr class="t-dcl-h">
<td> <div>可替换不抛出分配函数 <table class="t-rev-begin t-rev-begin-noborder">
<tr class="t-rev t-since-cxx11"><td>
<p><span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw1">noexcept</span></span></span>
</p>
</td>
<td><span class="t-mark-rev t-since-cxx11">(C++11 起)</span></td></tr>
</table> <table class="t-rev-begin t-rev-begin-noborder">
<tr class="t-rev t-since-cxx20"><td>
<p><span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="br0">[</span><span class="br0">[</span>nodiscard<span class="br0">]</span><span class="br0">]</span></span></span>
</p>
</td>
<td><span class="t-mark-rev t-since-cxx20">(C++20 起)</span></td></tr>
</table></div></td>
<td></td>
<td></td>
</tr>
<tr class="t-dcl">
<td> <div><span class="mw-geshi cpp source-cpp"><span class="kw4">void</span><span class="sy2">*</span> operator new  <span class="br0">(</span> <a href="../../types/size_t.html"><span class="kw100">std::<span class="me2">size_t</span></span></a> count, <span class="kw4">const</span> <a href="nothrow_t.html"><span class="kw694">std::<span class="me2">nothrow_t</span></span></a><span class="sy3">&amp;</span> tag<span class="br0">)</span><span class="sy4">;</span></span></div></td>
<td> (5) </td>
<td class="t-dcl-nopad">  </td>
</tr>
<tr class="t-dcl">
<td> <div><span class="mw-geshi cpp source-cpp"><span class="kw4">void</span><span class="sy2">*</span> operator new<span class="br0">[</span><span class="br0">]</span><span class="br0">(</span> <a href="../../types/size_t.html"><span class="kw100">std::<span class="me2">size_t</span></span></a> count, <span class="kw4">const</span> <a href="nothrow_t.html"><span class="kw694">std::<span class="me2">nothrow_t</span></span></a><span class="sy3">&amp;</span> tag<span class="br0">)</span><span class="sy4">;</span></span></div></td>
<td> (6) </td>
<td class="t-dcl-nopad">  </td>
</tr>
<tr class="t-dcl t-since-cxx17">
<td> <div><span class="mw-geshi cpp source-cpp"><span class="kw4">void</span><span class="sy2">*</span> operator new  <span class="br0">(</span> <a href="../../types/size_t.html"><span class="kw100">std::<span class="me2">size_t</span></span></a> count,<br>
                      <a href="align_val_t.html"><span class="kw695">std::<span class="me2">align_val_t</span></span></a> al, <span class="kw4">const</span> <a href="nothrow_t.html"><span class="kw694">std::<span class="me2">nothrow_t</span></span></a><span class="sy3">&amp;</span><span class="br0">)</span><span class="sy4">;</span></span></div></td>
<td> (7) </td>
<td> <span class="t-mark-rev t-since-cxx17">(C++17 起)</span> </td>
</tr>
<tr class="t-dcl t-since-cxx17">
<td> <div><span class="mw-geshi cpp source-cpp"><span class="kw4">void</span><span class="sy2">*</span> operator new<span class="br0">[</span><span class="br0">]</span><span class="br0">(</span> <a href="../../types/size_t.html"><span class="kw100">std::<span class="me2">size_t</span></span></a> count,<br>
                      <a href="align_val_t.html"><span class="kw695">std::<span class="me2">align_val_t</span></span></a> al, <span class="kw4">const</span> <a href="nothrow_t.html"><span class="kw694">std::<span class="me2">nothrow_t</span></span></a><span class="sy3">&amp;</span><span class="br0">)</span><span class="sy4">;</span></span></div></td>
<td> (8) </td>
<td> <span class="t-mark-rev t-since-cxx17">(C++17 起)</span> </td>
</tr>
<tr class="t-dcl-sep"><td></td><td></td><td></td></tr>
<tr class="t-dcl-h">
<td> <div>不分配布置分配函数 <table class="t-rev-begin t-rev-begin-noborder">
<tr class="t-rev t-since-cxx11"><td>
<p><span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw1">noexcept</span></span></span>
</p>
</td>
<td><span class="t-mark-rev t-since-cxx11">(C++11 起)</span></td></tr>
</table> <table class="t-rev-begin t-rev-begin-noborder">
<tr class="t-rev t-since-cxx20"><td>
<p><span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="br0">[</span><span class="br0">[</span>nodiscard<span class="br0">]</span><span class="br0">]</span></span></span>
</p>
</td>
<td><span class="t-mark-rev t-since-cxx20">(C++20 起)</span></td></tr>
</table></div></td>
<td></td>
<td></td>
</tr>
<tr class="t-dcl">
<td> <div><span class="mw-geshi cpp source-cpp"><span class="kw4">void</span><span class="sy2">*</span> operator new  <span class="br0">(</span> <a href="../../types/size_t.html"><span class="kw100">std::<span class="me2">size_t</span></span></a> count, <span class="kw4">void</span><span class="sy2">*</span> ptr <span class="br0">)</span><span class="sy4">;</span></span></div></td>
<td> (9) </td>
<td class="t-dcl-nopad">  </td>
</tr>
<tr class="t-dcl">
<td> <div><span class="mw-geshi cpp source-cpp"><span class="kw4">void</span><span class="sy2">*</span> operator new<span class="br0">[</span><span class="br0">]</span><span class="br0">(</span> <a href="../../types/size_t.html"><span class="kw100">std::<span class="me2">size_t</span></span></a> count, <span class="kw4">void</span><span class="sy2">*</span> ptr <span class="br0">)</span><span class="sy4">;</span></span></div></td>
<td> (10) </td>
<td class="t-dcl-nopad">  </td>
</tr>
<tr class="t-dcl-sep"><td></td><td></td><td></td></tr>
<tr class="t-dcl-h">
<td> <div>用户定义布置分配函数</div></td>
<td></td>
<td></td>
</tr>
<tr class="t-dcl">
<td> <div><span class="mw-geshi cpp source-cpp"><span class="kw4">void</span><span class="sy2">*</span> operator new  <span class="br0">(</span> <a href="../../types/size_t.html"><span class="kw100">std::<span class="me2">size_t</span></span></a> count, user<span class="sy2">-</span>defined<span class="sy2">-</span>args... <span class="br0">)</span><span class="sy4">;</span></span></div></td>
<td> (11) </td>
<td class="t-dcl-nopad">  </td>
</tr>
<tr class="t-dcl">
<td> <div><span class="mw-geshi cpp source-cpp"><span class="kw4">void</span><span class="sy2">*</span> operator new<span class="br0">[</span><span class="br0">]</span><span class="br0">(</span> <a href="../../types/size_t.html"><span class="kw100">std::<span class="me2">size_t</span></span></a> count, user<span class="sy2">-</span>defined<span class="sy2">-</span>args... <span class="br0">)</span><span class="sy4">;</span></span></div></td>
<td> (12) </td>
<td class="t-dcl-nopad">  </td>
</tr>
<tr class="t-dcl t-since-cxx17">
<td> <div><span class="mw-geshi cpp source-cpp"><span class="kw4">void</span><span class="sy2">*</span> operator new  <span class="br0">(</span> <a href="../../types/size_t.html"><span class="kw100">std::<span class="me2">size_t</span></span></a> count,<br>
                      <a href="align_val_t.html"><span class="kw695">std::<span class="me2">align_val_t</span></span></a> al, user<span class="sy2">-</span>defined<span class="sy2">-</span>args... <span class="br0">)</span><span class="sy4">;</span></span></div></td>
<td> (13) </td>
<td> <span class="t-mark-rev t-since-cxx17">(C++17 起)</span> </td>
</tr>
<tr class="t-dcl t-since-cxx17">
<td> <div><span class="mw-geshi cpp source-cpp"><span class="kw4">void</span><span class="sy2">*</span> operator new<span class="br0">[</span><span class="br0">]</span><span class="br0">(</span> <a href="../../types/size_t.html"><span class="kw100">std::<span class="me2">size_t</span></span></a> count, <br>
                      <a href="align_val_t.html"><span class="kw695">std::<span class="me2">align_val_t</span></span></a> al, user<span class="sy2">-</span>defined<span class="sy2">-</span>args... <span class="br0">)</span><span class="sy4">;</span></span></div></td>
<td> (14) </td>
<td> <span class="t-mark-rev t-since-cxx17">(C++17 起)</span> </td>
</tr>
<tr class="t-dcl-sep"><td></td><td></td><td></td></tr>
<tr class="t-dcl-h">
<td> <div>类特定分配函数</div></td>
<td></td>
<td></td>
</tr>
<tr class="t-dcl">
<td> <div><span class="mw-geshi cpp source-cpp"><span class="kw4">void</span><span class="sy2">*</span> T<span class="sy4">::</span><span class="me2">operator</span> new  <span class="br0">(</span> <a href="../../types/size_t.html"><span class="kw100">std::<span class="me2">size_t</span></span></a> count <span class="br0">)</span><span class="sy4">;</span></span></div></td>
<td> (15) </td>
<td class="t-dcl-nopad">  </td>
</tr>
<tr class="t-dcl">
<td> <div><span class="mw-geshi cpp source-cpp"><span class="kw4">void</span><span class="sy2">*</span> T<span class="sy4">::</span><span class="me2">operator</span> new<span class="br0">[</span><span class="br0">]</span><span class="br0">(</span> <a href="../../types/size_t.html"><span class="kw100">std::<span class="me2">size_t</span></span></a> count <span class="br0">)</span><span class="sy4">;</span></span></div></td>
<td> (16) </td>
<td class="t-dcl-nopad">  </td>
</tr>
<tr class="t-dcl t-since-cxx17">
<td> <div><span class="mw-geshi cpp source-cpp"><span class="kw4">void</span><span class="sy2">*</span> T<span class="sy4">::</span><span class="me2">operator</span> new  <span class="br0">(</span> <a href="../../types/size_t.html"><span class="kw100">std::<span class="me2">size_t</span></span></a> count, <a href="align_val_t.html"><span class="kw695">std::<span class="me2">align_val_t</span></span></a> al <span class="br0">)</span><span class="sy4">;</span></span></div></td>
<td> (17) </td>
<td> <span class="t-mark-rev t-since-cxx17">(C++17 起)</span> </td>
</tr>
<tr class="t-dcl t-since-cxx17">
<td> <div><span class="mw-geshi cpp source-cpp"><span class="kw4">void</span><span class="sy2">*</span> T<span class="sy4">::</span><span class="me2">operator</span> new<span class="br0">[</span><span class="br0">]</span><span class="br0">(</span> <a href="../../types/size_t.html"><span class="kw100">std::<span class="me2">size_t</span></span></a> count, <a href="align_val_t.html"><span class="kw695">std::<span class="me2">align_val_t</span></span></a> al <span class="br0">)</span><span class="sy4">;</span></span></div></td>
<td> (18) </td>
<td> <span class="t-mark-rev t-since-cxx17">(C++17 起)</span> </td>
</tr>
<tr class="t-dcl-sep"><td></td><td></td><td></td></tr>
<tr class="t-dcl-h">
<td> <div>类特定布置分配函数</div></td>
<td></td>
<td></td>
</tr>
<tr class="t-dcl">
<td> <div><span class="mw-geshi cpp source-cpp"><span class="kw4">void</span><span class="sy2">*</span> T<span class="sy4">::</span><span class="me2">operator</span> new  <span class="br0">(</span> <a href="../../types/size_t.html"><span class="kw100">std::<span class="me2">size_t</span></span></a> count, user<span class="sy2">-</span>defined<span class="sy2">-</span>args... <span class="br0">)</span><span class="sy4">;</span></span></div></td>
<td> (19) </td>
<td class="t-dcl-nopad">  </td>
</tr>
<tr class="t-dcl">
<td> <div><span class="mw-geshi cpp source-cpp"><span class="kw4">void</span><span class="sy2">*</span> T<span class="sy4">::</span><span class="me2">operator</span> new<span class="br0">[</span><span class="br0">]</span><span class="br0">(</span> <a href="../../types/size_t.html"><span class="kw100">std::<span class="me2">size_t</span></span></a> count, user<span class="sy2">-</span>defined<span class="sy2">-</span>args... <span class="br0">)</span><span class="sy4">;</span></span></div></td>
<td> (20) </td>
<td class="t-dcl-nopad">  </td>
</tr>
<tr class="t-dcl t-since-cxx17">
<td> <div><span class="mw-geshi cpp source-cpp"><span class="kw4">void</span><span class="sy2">*</span> T<span class="sy4">::</span><span class="me2">operator</span> new  <span class="br0">(</span> <a href="../../types/size_t.html"><span class="kw100">std::<span class="me2">size_t</span></span></a> count,<br>
                         <a href="align_val_t.html"><span class="kw695">std::<span class="me2">align_val_t</span></span></a> al, user<span class="sy2">-</span>defined<span class="sy2">-</span>args... <span class="br0">)</span><span class="sy4">;</span></span></div></td>
<td> (21) </td>
<td> <span class="t-mark-rev t-since-cxx17">(C++17 起)</span> </td>
</tr>
<tr class="t-dcl t-since-cxx17">
<td> <div><span class="mw-geshi cpp source-cpp"><span class="kw4">void</span><span class="sy2">*</span> T<span class="sy4">::</span><span class="me2">operator</span> new<span class="br0">[</span><span class="br0">]</span><span class="br0">(</span> <a href="../../types/size_t.html"><span class="kw100">std::<span class="me2">size_t</span></span></a> count,<br>
                         <a href="align_val_t.html"><span class="kw695">std::<span class="me2">align_val_t</span></span></a> al, user<span class="sy2">-</span>defined<span class="sy2">-</span>args... <span class="br0">)</span><span class="sy4">;</span></span></div></td>
<td> (22) </td>
<td> <span class="t-mark-rev t-since-cxx17">(C++17 起)</span> </td>
</tr>
<tr class="t-dcl-sep"><td></td><td></td><td></td></tr>
</tbody></table>
<p>分配请求数量的字节。这些分配函数为 <a href="../../language/new.html" title="cpp/language/new">new 表达式</a>所调用，以分配将被初始化的对象所在的内存。亦可用常规函数调用语法调用它们。
</p>
<div class="t-li1"><span class="t-li">1)</span> 为非数组 <a href="../../language/new.html" title="cpp/language/new">new 表达式</a>所调用，以分配为单个对象请求的存储。标准库实现从自由存储分配 <code>count</code> 字节。失败情况下，标准库实现调用 <span class="t-lc"><a href="get_new_handler.html" title="cpp/memory/new/get new handler">std::get_new_handler</a></span> 所返回的函数指针，并重复尝试分配，直到 new 处理函数不返回或成为空指针，在该时刻抛出 <span class="t-lc"><a href="bad_alloc.html" title="cpp/memory/new/bad alloc">std::bad_alloc</a></span> 。要求此函数返回指向拥有请求大小的对象的适当对齐的指针。</div>
<div class="t-li1"><span class="t-li">2)</span> 为 <a href="../../language/new.html" title="cpp/language/new">new[] 表达式</a>的数组形式所调用，以分配为数组请求的所有存储（包含可能的<i> new 表达式</i>开销）。标准库实现调用版本 <span class="t-v">(1)</span></div>
<div class="t-li1"><span class="t-li">3)</span> 为非数组 <a href="../../language/new.html" title="cpp/language/new">new 表达式</a>调用，以分配对齐要求超出 <code>__STDCPP_DEFAULT_NEW_ALIGNMENT__</code> 的单个对象所要求的存储</div>
<div class="t-li1"><span class="t-li">4)</span> 为 <a href="../../language/new.html" title="cpp/language/new">new[] 表达式</a>的数组形式调用，以分配对齐要求超出 <code>__STDCPP_DEFAULT_NEW_ALIGNMENT__</code> 的对象数组要求的所有存储</div>
<div class="t-li1"><span class="t-li">5)</span> 为不抛出非数组 <a href="../../language/new.html" title="cpp/language/new">new 表达式</a>所调用。标准库实现调用版本 <span class="t-v">(1)</span> 并在失败时不传播异常而抛出空指针。</div>
<div class="t-li1"><span class="t-li">6)</span> 为 <a href="../../language/new.html" title="cpp/language/new">new[] 表达式</a>的不抛出数组形式所调用。标准库实现调用版本 <span class="t-v">(2)</span> 并在失败时不传播异常而抛出空指针。</div>
<div class="t-li1"><span class="t-li">7)</span> 在对象对齐要求超出 <code>__STDCPP_DEFAULT_NEW_ALIGNMENT__</code> 时为不抛出非数组 <a href="../../language/new.html" title="cpp/language/new">new 表达式</a>所调用。标准库实现调用版本 <span class="t-v">(3)</span> 并在失败时不传播异常而抛出空指针。</div>
<div class="t-li1"><span class="t-li">8)</span> 在数组元素的对齐要求超出 <code>__STDCPP_DEFAULT_NEW_ALIGNMENT__</code> 时为 <a href="../../language/new.html" title="cpp/language/new">new[] 表达式</a>的不抛出数组形式所调用。标准库实现调用版本 <span class="t-v">(4)</span> 并在失败时不传播异常而抛出空指针。</div>
<div class="t-li1"><span class="t-li">9)</span> 为标准单对象<a href="../../language/new.html" title="cpp/language/new">布置 new</a> 表达式所调用，标准库实现不进行任何动作并返回不修改的 <code>ptr</code> 。若通过布置 new 表达式调用此函数而 <code>ptr</code> 为空指针则行为未定义。</div>
<div class="t-li1"><span class="t-li">10)</span> 为标准数组形式<a href="../../language/new.html" title="cpp/language/new">布置 new</a> 表达式所调用。标准库实现不进行任何动作并返回不修改的 <code>ptr</code> 。若通过布置 new 表达式调用此函数而 <code>ptr</code> 为空指针则行为未定义。</div>
<div class="t-li1"><span class="t-li">11)</span> 若定义，则为拥有匹配签名的自定义单对象<a href="../../language/new.html" title="cpp/language/new">布置 new</a> 表达式所调用。若定义类特定版本 <span class="t-v">(19)</span> ，则优先于 <span class="t-v">(11)</span> 调用类特定版本。若用户既不提供 <span class="t-v">(11)</span> 又不提供 <span class="t-v">(19)</span> ，则布置 new 表达式为病式。</div>
<div class="t-li1"><span class="t-li">12)</span> 若定义，则为拥有匹配签名的自定义数组形式<a href="../../language/new.html" title="cpp/language/new">布置 new</a> 表达式所调用。若定义类特定版本 <span class="t-v">(20)</span> ，则优先于 <span class="t-v">(12)</span> 调用类特定版本。若用户既不提供 <span class="t-v">(12)</span> 又不提供 <span class="t-v">(20)</span> ，则布置 new 表达式为病式。</div>
<div class="t-li1"><span class="t-li">13)</span> 若定义，则为拥有匹配签名的自定义单对象<a href="../../language/new.html" title="cpp/language/new">布置 new</a> 表达式所调用，若对象的对齐要求超出 <code>__STDCPP_DEFAULT_NEW_ALIGNMENT__</code> 。若定义类特定版本（ <span class="t-v">(15)</span> 或 <span class="t-v">(17)</span> ），则调用之。若既不提供类特定版本又不提供具对齐布置形式（此形式），则替而查找无对齐布置形式 <span class="t-v">(11)</span> 。</div>
<div class="t-li1"><span class="t-li">14)</span> 若定义，则为拥有匹配签名的自定义数组形式<a href="../../language/new.html" title="cpp/language/new">布置 new</a> 表达式所调用，若元素的对齐要求超出 <code>__STDCPP_DEFAULT_NEW_ALIGNMENT__</code> 。若定义类特定版本（<span class="t-v">(16)</span>  或 <span class="t-v">(18)</span> ），则调用之。若既不提供类特定版本又不提供具对齐布置形式（此形式），则替而查找无对齐布置形式 <span class="t-v">(12)</span> 。</div>
<div class="t-li1"><span class="t-li">15)</span> 若定义，则为通常的单对象 <a href="../../language/new.html" title="cpp/language/new">new 表达式</a>所调用，若在分配 T 类型对象。</div>
<div class="t-li1"><span class="t-li">16)</span> 若定义，则为通常的数组 <a href="../../language/new.html" title="cpp/language/new">new[] 表达式</a>所调用，若在分配 T 类型对象的数组。</div>
<div class="t-li1"><span class="t-li">17)</span> 若定义，则为通常的单对象 <a href="../../language/new.html" title="cpp/language/new">new 表达式</a>所调用，若在分配 T 类型对象，且其对齐要求超出 <code>__STDCPP_DEFAULT_NEW_ALIGNMENT__</code> 。若不提供此重载，但提供了无对齐成员形式 <span class="t-v">(15)</span> ，则调用无对齐成员重载。</div>
<div class="t-li1"><span class="t-li">18)</span> 若定义，通常的数组 <a href="../../language/new.html" title="cpp/language/new">new[] 表达式</a>所调用，若在分配 T 类型的对象数组，且其对齐要求超出 <code>__STDCPP_DEFAULT_NEW_ALIGNMENT__</code> 。若不提供此重载，但提供了无对齐成员形式 <span class="t-v">(16)</span> ，则调用无对齐成员重载。</div>
<div class="t-li1"><span class="t-li">19)</span> 若定义，则为拥有匹配签名的自定义单对象<a href="../../language/new.html" title="cpp/language/new">布置 new</a> 表达式所调用，若在分配 T 类型对象。</div>
<div class="t-li1"><span class="t-li">20)</span> 若定义，则为拥有匹配签名的自定义数组形式<a href="../../language/new.html" title="cpp/language/new">布置 new</a> 表达式所调用，若在分配 T 类型对象的数组。</div>
<div class="t-li1"><span class="t-li">21)</span> 若定义，则为拥有匹配签名的自定义单对象<a href="../../language/new.html" title="cpp/language/new">布置 new</a> 表达式所调用，若在分配 T 类型对象，且其对齐要求超出 <code>__STDCPP_DEFAULT_NEW_ALIGNMENT__</code> 。若不提供此重载，但提供了无对齐成员形式 <span class="t-v">(19)</span> ，则调用无对齐成员重载。</div>
<div class="t-li1"><span class="t-li">22)</span> 若定义，则为拥有匹配签名的自定义数组形式<a href="../../language/new.html" title="cpp/language/new">布置 new</a> 表达式所调用，若在分配 T 类型的对象数组，且其对齐要求超出 <code>__STDCPP_DEFAULT_NEW_ALIGNMENT__</code> 。若不提供此重载，但提供了无对齐成员形式 <span class="t-v">(20)</span> ，则调用无对齐成员重载。</div>
<h3><span class="mw-headline" id=".E5.8F.82.E6.95.B0">参数</span></h3>
<table class="t-par-begin">


<tr class="t-par">
<td>  count
</td>
<td> -
</td>
<td>  要分配的字节数
</td></tr>
<tr class="t-par">
<td>  ptr
</td>
<td> -
</td>
<td>  指向要初始化的对象所在的内存区域的指针
</td></tr>
<tr class="t-par">
<td>  tag
</td>
<td> -
</td>
<td>  用于选择不抛出重载的消歧义标签
</td></tr>
<tr class="t-par">
<td>  al
</td>
<td> -
</td>
<td>  使用的对齐。若此非有效对齐值，则行为未定义
</td></tr></table>
<h3><span class="mw-headline" id=".E8.BF.94.E5.9B.9E.E5.80.BC">返回值</span></h3>
<div class="t-li1"><span class="t-li">1-4)</span> 非空指针，指向拥有至少 <code>size</code> 大小的适当对齐的内存</div>
<div class="t-li1"><span class="t-li">5-8)</span> 非空指针，指向拥有至少 <code>size</code> 大小的适当对齐的内存，或在失败时为空指针</div>
<div class="t-li1"><span class="t-li">9-10)</span> <code>ptr</code></div>
<div class="t-li1"><span class="t-li">11-22)</span> 若函数在分配失败时不返回则同 <span class="t-v">(1-4)</span> ，否则同 <span class="t-v">(5-8)</span></div>
<h3><span class="mw-headline" id=".E5.BC.82.E5.B8.B8">异常</span></h3>
<div class="t-li1"><span class="t-li">1-4)</span> 在分配内存失败时抛出 <span class="t-lc"><a href="bad_alloc.html" title="cpp/memory/new/bad alloc">std::bad_alloc</a></span> <span class="t-rev-inl t-since-cxx11"><span>或任何从 <span class="t-lc"><a href="bad_alloc.html" title="cpp/memory/new/bad alloc">std::bad_alloc</a></span> 派生的异常</span> <span><span class="t-mark-rev t-since-cxx11">(C++11 起)</span></span></span></div>
<div class="t-li1"><span class="t-li">11-22)</span> 若函数在分配失败时不返回则同 <span class="t-v">(1-4)</span> ，否则同 <span class="t-v">(5-8)</span></div>
<h3><span class="mw-headline" id=".E5.85.A8.E5.B1.80.E6.9B.BF.E6.8D.A2">全局替换</span></h3>
<p>版本 <span class="t-v">(1-4)</span> 在每个翻译单元隐式声明，即使不包含 <code>&lt;new&gt;</code> 头文件。版本 <span class="t-v">(1-8)</span> 是<i>可替换</i>的：定义于程序任何位置，在任何源文件的用户提供的拥有相同签名的非成员函数，会替换默认版本。其声明不必可见。
</p><p>若程序中为任何可替换分配函数提供多于一个替换版本，或若替换定义带 <code>inline</code> 指定符，则行为未定义。若替换定义于异于全局命名空间的命名空间中，或它定义为在全局作用域的 static 函数，则程序为病式。
</p>
 <table class="t-rev-begin">
<tr class="t-rev t-since-cxx11"><td>
<p>nothrow 版本的标准库实现 <span class="t-v">(5-8)</span> 直接调用对应的抛出版本 <span class="t-v">(1-4)</span> 。抛出的数组版本的标准库实现 <span class="t-v">(2,4)</span> 直接调用对应的单对象版本 <span class="t-v">(1,3)</span> 。故而，替换抛出单对象分配函数足以处理所有分配。
</p>
</td>
<td><span class="t-mark-rev t-since-cxx11">(C++11 起)</span></td></tr>
</table>
<div class="t-example"><div class="t-example-live-link"><div class="coliru-btn coliru-btn-run-init">运行此代码</div></div>
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="cpp source-cpp"><pre class="de1"><span class="co2">#include &lt;cstdio&gt;</span>
<span class="co2">#include &lt;cstdlib&gt;</span>
<span class="co1">// 函数最小集的替换：</span>
<span class="kw4">void</span><span class="sy2">*</span> operator new<span class="br0">(</span><a href="../../types/size_t.html"><span class="kw100">std::<span class="me2">size_t</span></span></a> sz<span class="br0">)</span> <span class="br0">{</span>
    <a href="../../io/c/fprintf.html"><span class="kw1843">std::<span class="me2">printf</span></span></a><span class="br0">(</span><span class="st0">"global op new called, size = %zu<span class="es1">\n</span>"</span>,sz<span class="br0">)</span><span class="sy4">;</span>
    <span class="kw4">void</span> <span class="sy2">*</span>ptr <span class="sy1">=</span> <a href="../c/malloc.html"><span class="kw757">std::<span class="me2">malloc</span></span></a><span class="br0">(</span>sz<span class="br0">)</span><span class="sy4">;</span>
    <span class="kw1">if</span> <span class="br0">(</span>ptr<span class="br0">)</span>
        <span class="kw1">return</span> ptr<span class="sy4">;</span>
    <span class="kw1">else</span>
        <span class="kw1">throw</span> <a href="bad_alloc.html"><span class="kw691">std::<span class="me2">bad_alloc</span></span></a><span class="br0">{</span><span class="br0">}</span><span class="sy4">;</span>
<span class="br0">}</span>
<span class="kw4">void</span> <a href="operator_delete.html"><span class="kw687">operator delete</span></a><span class="br0">(</span><span class="kw4">void</span><span class="sy2">*</span> ptr<span class="br0">)</span> <span class="kw1">noexcept</span>
<span class="br0">{</span>
    <a href="../../io/c/puts.html"><span class="kw1828">std::<span class="me2">puts</span></span></a><span class="br0">(</span><span class="st0">"global op delete called"</span><span class="br0">)</span><span class="sy4">;</span>
    <a href="../c/free.html"><span class="kw761">std::<span class="me2">free</span></span></a><span class="br0">(</span>ptr<span class="br0">)</span><span class="sy4">;</span>
<span class="br0">}</span>
<span class="kw4">int</span> main<span class="br0">(</span><span class="br0">)</span> <span class="br0">{</span>
     <span class="kw4">int</span><span class="sy2">*</span> p1 <span class="sy1">=</span> new <span class="kw4">int</span><span class="sy4">;</span>
     delete p1<span class="sy4">;</span>
 
     <span class="kw4">int</span><span class="sy2">*</span> p2 <span class="sy1">=</span> new <span class="kw4">int</span><span class="br0">[</span><span class="nu0">10</span><span class="br0">]</span><span class="sy4">;</span> <span class="co1">// C++11 中保证调用替换者</span>
     delete<span class="br0">[</span><span class="br0">]</span> p2<span class="sy4">;</span>
<span class="br0">}</span></pre></div></div>
<p>可能的输出：
</p>
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="text source-text"><pre class="de1">global op new called, size = 4
global op delete called
global op new called, size = 40
global op delete called</pre></div></div> 
</div>
<p><code>operator new</code> 与 <code>operator new[]</code> 带额外用户定义参数的重载（“布置形式”，版本 <span class="t-v">(11-14)</span> ）可以照常声明于全局作用于，而且为匹配的<i> new 表达式</i>的布置形式所调用。
</p><p>标准库的 operator new 的不分配布置形式 <span class="t-v">(9-10)</span> 不能被替换，而且只若布置 new 表达式不使用 <code>::new</code> 语法才能自定义，通过提供类特定的带匹配签名的布置 new <span class="t-v">(19,20)</span> ： <code>void* T::operator new(size_t, void*)</code> 或 <code>void* T::operator new[](size_t, void*)</code> 。
</p>
 <table class="t-rev-begin">
<tr class="t-rev t-since-cxx14"><td>
<p>布置形式 <code>void* operator new(std::size_t, std::size_t)</code> 不被允许，因为对应的解分配函数的匹配签名 <code>void operator delete(void*, std::size_t)</code> 是通常（非布置）的解分配函数。
</p>
</td>
<td><span class="t-mark-rev t-since-cxx14">(C++14 起)</span></td></tr>
</table>
<h3><span class="mw-headline" id=".E7.B1.BB.E7.89.B9.E5.AE.9A.E9.87.8D.E8.BD.BD">类特定重载</span></h3>
<p>单对象和数组分配函数都可以定义为类的公开静态成员函数（版本 <span class="t-v">(15-18)</span> 。若定义，则 <a href="../../language/new.html" title="cpp/language/new">new 表达式</a>调用这些函数，以分配此类单个对象或数组的内存，除非 new 表达式使用 <code>::new</code> 形式，这跳过类作用域查找。关键词 <code>static</code> 对这些函数可选：不管是否使用，分配函数都是静态成员函数。
</p><p>new 表达式首先在类作用域中查找适当的函数名，然后在全局作用域查找。注意，同每个<a href="../../language/lookup.html" title="cpp/language/lookup">名称查找规则</a>，就试图分配此类对象的 new 表达式而言，任何声明于类作用域的分配函数隐藏所有全局分配函数。
</p>
 <table class="t-rev-begin">
<tr class="t-rev t-since-cxx17"><td>
<p>在分配对齐超出 <code>__STDCPP_DEFAULT_NEW_ALIGNMENT__</code> 的对象或对象数组时，进行二次重载决议：首先，针对具对齐的函数签名，然后，针对无对齐的函数签名。这表示若拥有扩展对齐的类拥有无对齐量的类特定分配函数，则将被调用者是该函数，而非全局的具对齐分配函数。这是有意的：期待类成员对如何处理该类的理解是最好的。
</p>
</td>
<td><span class="t-mark-rev t-since-cxx17">(C++17 起)</span></td></tr>
</table>
<div class="t-example"><div class="t-example-live-link"><div class="coliru-btn coliru-btn-run-init">运行此代码</div></div>
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="cpp source-cpp"><pre class="de1"><span class="co2">#include &lt;iostream&gt;</span>
<span class="co1">// 类特定分配函数</span>
<span class="kw1">struct</span> X <span class="br0">{</span>
    <span class="kw4">static</span> <span class="kw4">void</span><span class="sy2">*</span> operator new<span class="br0">(</span><a href="../../types/size_t.html"><span class="kw100">std::<span class="me2">size_t</span></span></a> sz<span class="br0">)</span>
    <span class="br0">{</span>
        <a href="../../io/cout.html"><span class="kw1756">std::<span class="me2">cout</span></span></a> <span class="sy1">&lt;&lt;</span> <span class="st0">"custom new for size "</span> <span class="sy1">&lt;&lt;</span> sz <span class="sy1">&lt;&lt;</span> <span class="st0">'<span class="es1">\n</span>'</span><span class="sy4">;</span>
        <span class="kw1">return</span> <span class="sy4">::</span><span class="me2">operator</span> new<span class="br0">(</span>sz<span class="br0">)</span><span class="sy4">;</span>
    <span class="br0">}</span>
    <span class="kw4">static</span> <span class="kw4">void</span><span class="sy2">*</span> operator new<span class="br0">[</span><span class="br0">]</span><span class="br0">(</span><a href="../../types/size_t.html"><span class="kw100">std::<span class="me2">size_t</span></span></a> sz<span class="br0">)</span>
    <span class="br0">{</span>
        <a href="../../io/cout.html"><span class="kw1756">std::<span class="me2">cout</span></span></a> <span class="sy1">&lt;&lt;</span> <span class="st0">"custom new for size "</span> <span class="sy1">&lt;&lt;</span> sz <span class="sy1">&lt;&lt;</span> <span class="st0">'<span class="es1">\n</span>'</span><span class="sy4">;</span>
        <span class="kw1">return</span> <span class="sy4">::</span><span class="me2">operator</span> new<span class="br0">(</span>sz<span class="br0">)</span><span class="sy4">;</span>
    <span class="br0">}</span>
<span class="br0">}</span><span class="sy4">;</span>
<span class="kw4">int</span> main<span class="br0">(</span><span class="br0">)</span> <span class="br0">{</span>
     X<span class="sy2">*</span> p1 <span class="sy1">=</span> new X<span class="sy4">;</span>
     delete p1<span class="sy4">;</span>
     X<span class="sy2">*</span> p2 <span class="sy1">=</span> new X<span class="br0">[</span><span class="nu0">10</span><span class="br0">]</span><span class="sy4">;</span>
     delete<span class="br0">[</span><span class="br0">]</span> p2<span class="sy4">;</span>
<span class="br0">}</span></pre></div></div>
<p>可能的输出：
</p>
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="text source-text"><pre class="de1">custom new for size 1
custom new for size 10</pre></div></div> 
</div>
<p><code>operator new</code> 与 <code>operator new[]</code> 带额外用户定义参数（“布置形式”）的重载，亦可定义为类成员 <span class="t-v">(19-22)</span> 。在拥有匹配签名的布置 new 表达式查找要调用的对应分配函数时，查找在检验全局作用域前，从类作用域开始，而若提供了类特定的布置 new 则调用它。
</p>
 <table class="t-rev-begin">
<tr class="t-rev t-since-cxx17"><td>
<p>在分配对齐超出 <code>__STDCPP_DEFAULT_NEW_ALIGNMENT__</code> 的对象或对象数组时，布置形式的重载决议如常规形式一样执行二次：首先，对有对齐量的函数签名，然后，对无对齐量的函数签名。
</p>
</td>
<td><span class="t-mark-rev t-since-cxx17">(C++17 起)</span></td></tr>
</table>
<div class="t-example"><div class="t-example-live-link"><div class="coliru-btn coliru-btn-run-init">运行此代码</div></div>
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="cpp source-cpp"><pre class="de1"><span class="co2">#include &lt;stdexcept&gt;</span>
<span class="co2">#include &lt;iostream&gt;</span>
<span class="kw1">struct</span> X <span class="br0">{</span>
    X<span class="br0">(</span><span class="br0">)</span> <span class="br0">{</span> <span class="kw1">throw</span> <a href="../../error/runtime_error.html"><span class="kw768">std::<span class="me2">runtime_error</span></span></a><span class="br0">(</span><span class="st0">""</span><span class="br0">)</span><span class="sy4">;</span> <span class="br0">}</span>
    <span class="co1">// 自定义布置 new</span>
    <span class="kw4">static</span> <span class="kw4">void</span><span class="sy2">*</span> operator new<span class="br0">(</span><a href="../../types/size_t.html"><span class="kw100">std::<span class="me2">size_t</span></span></a> sz, <span class="kw4">bool</span> b<span class="br0">)</span> <span class="br0">{</span>
        <a href="../../io/cout.html"><span class="kw1756">std::<span class="me2">cout</span></span></a> <span class="sy1">&lt;&lt;</span> <span class="st0">"custom placement new called, b = "</span> <span class="sy1">&lt;&lt;</span> b <span class="sy1">&lt;&lt;</span> <span class="st0">'<span class="es1">\n</span>'</span><span class="sy4">;</span>
        <span class="kw1">return</span> <span class="sy4">::</span><span class="me2">operator</span> new<span class="br0">(</span>sz<span class="br0">)</span><span class="sy4">;</span>
    <span class="br0">}</span>
    <span class="co1">// 自定义布置 delete</span>
    <span class="kw4">static</span> <span class="kw4">void</span> <a href="operator_delete.html"><span class="kw687">operator delete</span></a><span class="br0">(</span><span class="kw4">void</span><span class="sy2">*</span> ptr, <span class="kw4">bool</span> b<span class="br0">)</span>
    <span class="br0">{</span>
        <a href="../../io/cout.html"><span class="kw1756">std::<span class="me2">cout</span></span></a> <span class="sy1">&lt;&lt;</span> <span class="st0">"custom placement delete called, b = "</span> <span class="sy1">&lt;&lt;</span> b <span class="sy1">&lt;&lt;</span> <span class="st0">'<span class="es1">\n</span>'</span><span class="sy4">;</span>
        <span class="sy4">::</span><a href="operator_delete.html"><span class="kw687">operator delete</span></a><span class="br0">(</span>ptr<span class="br0">)</span><span class="sy4">;</span>
    <span class="br0">}</span>
<span class="br0">}</span><span class="sy4">;</span>
<span class="kw4">int</span> main<span class="br0">(</span><span class="br0">)</span> <span class="br0">{</span>
   <span class="kw1">try</span> <span class="br0">{</span>
     X<span class="sy2">*</span> p1 <span class="sy1">=</span> new <span class="br0">(</span><span class="kw2">true</span><span class="br0">)</span> X<span class="sy4">;</span>
   <span class="br0">}</span> <span class="kw1">catch</span><span class="br0">(</span><span class="kw4">const</span> <a href="../../error/exception.html"><span class="kw762">std::<span class="me2">exception</span></span></a><span class="sy3">&amp;</span><span class="br0">)</span> <span class="br0">{</span> <span class="br0">}</span>
<span class="br0">}</span></pre></div></div>
<p>输出：
</p>
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="text source-text"><pre class="de1">custom placement new called, b = 1
custom placement delete called, b = 1</pre></div></div> 
</div>
<p>若类级别的 <code>operator new</code> 是模板函数，则它必须拥有返回类型 <code>void*</code> ，第一参数类型 <code>std::size_t</code> ，且它必须拥有二个或更多参数。换言之，仅布置形式能是模板。
</p>
<h3><span class="mw-headline" id=".E6.B3.A8.E8.A7.A3">注解</span></h3>
<p>尽管不分配布置 new <span class="t-v">(9,10)</span> 不能被替换，亦可在上面描述的类作用域定义拥有相同签名的函数。而且，像是布置 new 但接受非 void 指针类型作为第二参数的全局重载是的受到允许的，故意图确保调用真的布置 new 的代码（例如 <span class="t-lc"><a href="../allocator/construct.html" title="cpp/memory/allocator/construct">std::allocator::construct</a></span> ）必须使用 <code>::new</code> 并将指针转型到 <code>void*</code> 。
</p>
 <table class="t-rev-begin">
<tr class="t-rev t-since-cxx11"><td>
<p>要求下列函数是线程安全的：
</p>
<ul><li> <strong class="selflink"><tt>operator new</tt></strong> 及 <a href="operator_delete.html" title="cpp/memory/new/operator delete"><tt>operator delete</tt></a> 的库版本
</li><li> 全局 <strong class="selflink"><tt>operator new</tt></strong> 与 <a href="operator_delete.html" title="cpp/memory/new/operator delete"><tt>operator delete</tt></a> 的用户替换版本
</li><li> <span class="t-lc"><a href="../c/calloc.html" title="cpp/memory/c/calloc">std::calloc</a></span> 、 <span class="t-lc"><a href="../c/malloc.html" title="cpp/memory/c/malloc">std::malloc</a></span> 、 <span class="t-lc"><a href="../c/realloc.html" title="cpp/memory/c/realloc">std::realloc</a></span><span class="t-rev-inl t-since-cxx17"><span> 、 <span class="t-lc"><a href="../c/aligned_alloc.html" title="cpp/memory/c/aligned alloc">std::aligned_alloc</a></span></span> <span><span class="t-mark-rev t-since-cxx17">(C++17 起)</span></span></span> 、 <span class="t-lc"><a href="../c/free.html" title="cpp/memory/c/free">std::free</a></span>
</li></ul>
<p>对这些分配或解分配特定存储单元的函数调用以单独全序出现，并且在此顺序中，每个解分配调用<a href="../../atomic/memory_order.html" title="cpp/atomic/memory order">先发生于</a>下个分配（若存在）。
</p>
</td>
<td><span class="t-mark-rev t-since-cxx11">(C++11 起)</span></td></tr>
</table>
<p><code>operator new</code> 的库版本是否产生任何对 <span class="t-lc"><a href="../c/malloc.html" title="cpp/memory/c/malloc">std::malloc</a></span> <span class="t-rev-inl t-since-cxx17"><span>或 <span class="t-lc"><a href="../c/aligned_alloc.html" title="cpp/memory/c/aligned alloc">std::aligned_alloc</a></span></span> <span><span class="t-mark-rev t-since-cxx17">(C++17 起)</span></span></span> 的调用是未指定的。
</p>
<h3><span class="mw-headline" id=".E7.A4.BA.E4.BE.8B">示例</span></h3>
<table class="metadata plainlinks ambox mbox-small-left ambox-notice" style=""><tr><td class="mbox-empty-cell"></td><td class="mbox-text" style="">本节未完成<br>原因：暂无示例 </td></tr></table>
<h3><span class="mw-headline" id=".E5.8F.82.E9.98.85">参阅</span></h3>
<table class="t-dsc-begin">

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="operator_delete.html" title="cpp/memory/new/operator delete"> <span class="t-lines"><span>operator delete</span><span>operator delete[]</span></span></a></div></div>
</td>
<td>   解分配函数  <br> <span class="t-mark">(函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="get_new_handler.html" title="cpp/memory/new/get new handler"> <span class="t-lines"><span>get_new_handler</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
</td>
<td>   获得当前的 new 处理函数  <br> <span class="t-mark">(函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="set_new_handler.html" title="cpp/memory/new/set new handler"> <span class="t-lines"><span>set_new_handler</span></span></a></div></div>
</td>
<td>   注册一个 new 处理函数 <br> <span class="t-mark">(函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="../get_temporary_buffer.html" title="cpp/memory/get temporary buffer"> <span class="t-lines"><span>get_temporary_buffer</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-deprecated-cxx17">(C++17 中弃用)</span></span><span><span class="t-mark-rev t-until-cxx20">(C++20 中移除)</span></span></span></div></div>
</td>
<td>  获得未初始化存储 <br> <span class="t-mark">(函数模板)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="../c/malloc.html" title="cpp/memory/c/malloc"> <span class="t-lines"><span>malloc</span></span></a></div></div>
</td>
<td>   分配内存 <br> <span class="t-mark">(函数)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="../c/aligned_alloc.html" title="cpp/memory/c/aligned alloc"> <span class="t-lines"><span>aligned_alloc</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div>
</td>
<td>   分配对齐的内存 <br> <span class="t-mark">(函数)</span>
</td></tr>
</table>
<h3><span class="mw-headline" id=".E5.BC.95.E7.94.A8">引用</span></h3>
<div class="t-ref-std-c++11">
<ul><li> C++11 standard (ISO/IEC 14882:2011): 
</li></ul>
<dl><dd><ul><li> 18.6 Dynamic memory management [support.dynamic]
</li></ul>
</dd></dl>
</div>

<!-- 
NewPP limit report
Preprocessor visited node count: 13990/1000000
Preprocessor generated node count: 18254/1000000
Post‐expand include size: 336735/2097152 bytes
Template argument size: 75115/2097152 bytes
Highest expansion depth: 22/40
Expensive parser function count: 0/100
-->

<!-- Saved in parser cache with key mwiki1-mwiki_zh_:pcache:idhash:2958-0!*!0!!zh!*!zh!* and timestamp 20200312142012 -->
</div>                    <!-- /bodycontent -->
                                        <!-- printfooter -->
                    <div class="printfooter">
                    来自“<a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/memory/new/operator_new&amp;oldid=65278">https://zh.cppreference.com/mwiki/index.php?title=cpp/memory/new/operator_new&amp;oldid=65278</a>”                    </div>
                    <!-- /printfooter -->
                                                            <!-- catlinks -->
                    <!-- /catlinks -->
                                                            <div class="visualClear"></div>
                    <!-- debughtml -->
                                        <!-- /debughtml -->
                </div>
                <!-- /bodyContent -->
            </div>
        </div>
        <!-- /content -->
        <!-- footer -->
        <div id="cpp-footer-base" class="noprint">
            <div id="footer">
                        <div id="cpp-navigation">
            <h5>导航</h5>
            <ul><li><a href="https://zh.cppreference.com/w/cpp/memory/new/operator_new">Online version</a></li><li>Offline version retrieved 2020-03-14 18:00.</li></ul></div>
                        <ul id="footer-info">
                                    <li id="footer-info-lastmod"> 本页面最后修改于2020年3月12日 (星期四) 07:20。</li>
                                    <li id="footer-info-viewcount">此页面已被浏览过11,090次。</li>
                            </ul>
                    </div>
        </div>
        <!-- /footer -->
        <script>if(window.mw){
mw.loader.state({"site":"loading","user":"missing","user.groups":"ready"});
}</script>
<script src="../../../../common/skin_scripts.js"></script>
<script>if(window.mw){
mw.loader.load(["mediawiki.action.view.postEdit","mediawiki.user","mediawiki.page.ready","mediawiki.searchSuggest","mediawiki.hidpi","ext.gadget.MathJax","ext.gadget.ColiruCompiler"], null, true);
}</script>
<script src="../../../../common/site_scripts.js"></script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-2828341-1']);
_gaq.push(['_setDomainName', 'cppreference.com']);
_gaq.push(['_trackPageview']);
</script><!-- Served in 0.084 secs. -->
	</body>
<!-- Cached 20200312151342 -->
</html>